There are no applications related to the present application.
1. Field of the Invention
The present invention relates generally to semiconductor microprocessors, a class of which is known as microcontrollers, that perform selective functions, and more particularly, to a microcontroller that selectively executes instructions.
2. Description of the Related Technology
The evolution of microprocessors into complex instruments and machines has led to sophisticated, fast real-time control capability. Large microprocessors of 16 or 32 bit capability with associated interrupt handler chips, programmable timer chips, ROM and RAM chips, have been replaced in many control function instances by single chip I/O microcontrollers with all peripherals embedded on the same chip with the microcontroller. Operation of the chip in an expanded mode enhances the versatility of all on-chip features.
Microcontrollers have a wide diversity of applications. In hand-held devices such as pocket pagers (beepers), the microcontroller is responsive to received characters, first to interpret them, then produce an audible or vibratory signal, to notify the user of an incoming message, and produce multiple alphanumeric messages on a suitable display such as an LCD. The microcontroller can recall from its internal memory any or all of the messages received in a given period of time. Among other instrumentation uses are those as meters and testers, capable of carrying out thousands of tests, each in a millisecond or less.
Other applications include keyboard controllers for personal computers, in which the microcontroller serves to off-load many tasks formerly handled by the processor, including continuous performance of numerous diagnostic procedures and notification to the processor if a problem is detected. Personal computer applications of microcontrollers include use in modems for command interpretation and data transmission, in printer buffers for high speed dumping of data in preparation for driving the printer at the appropriate speed, and in color plotters, copiers, electronic typewriters/word processors, cable television terminal equipment, lawn sprinkling controllers, credit card phone equipment, cellular telephones, fax machines, automotive applications such as engine control modules, anti-lock braking systems, automobile suspension control, keyless entry systems, and a host of other industrial and consumer applications.
Typically, a microcontroller includes, among other things, a CPU (central processing unit), a program memory from which the CPU fetches instructions, and a data memory (also called a register file in some architectures) which is readable and writable directly by the CPU. The CPU fetches an instruction from the program memory and addresses the data memory according to an address obtained through the instruction or through an indirect register. The CPU may also operate in conjunction with certain peripherals to perform the control function, including devices such as timers, signal ports, and baud rate generators, among others.
More recently, microcontrollers have been embedded into appliances, such as automobiles or coffee makers, and are used to control certain electromechanical devices within the appliance. Embedded control products are found in all market segments: consumer, commercial, PC peripherals, telecommunications (including personal telecom products), automotive and industrial. Most embedded control products must meet special requirements: cost effectiveness, low-power, small-footprint and a high level of system integration.
Typically, most embedded control systems are designed around a MCU which integrates on-chip program memory, data memory (RAM) and various peripheral functions, such as timers and serial communication. In addition, these systems usually require complementary serial EEPROM, display drivers, key pads or small displays. Variable parameter settings for the microcontroller, if any, are usually through the displays and key pads that are controlled by the operator.
In the prior art, microcontrollers include program memory that stores instructions that can be executed on, for example, a microprocessor. Normally, the variable length coded instructions that are stored in the program memory require multiple read statements in order to obtain the complete instruction, particularly on 8-bit processors. Once the complete coded instruction is obtained, it must be decoded before it can be executed. Consequently, the execution of an instruction requires three basic steps: fetch, decode, and execute.
The instruction is first fetched from memory and transferred inside the microprocessor into a special register of the control unit called the instruction register (IR). Once in the IR, the fetched instruction is decoded by a decoder. Finally, the decoded instruction is executed. The appropriate sequence of signals is generated by the control logic unit, resulting in the appropriate data transfers and operations. The execution of an instruction is illustrated in FIG. 1. The microprocessor unit (MPU) chip 10 appears on the left, and a memory chip 12 (ROM or RAM) containing the program (instructions) 14 appears on the right.
The first phase is the instruction fetch: The contents of the program counter (PC) 16 are output to the address bus 18 and a memory location is selected, in the example shown in FIG. 1, memory location 2304 (designated by numeral 15 in FIG. 1). A read command 22 is then given to the memory 12. After a period of nanosecondsxe2x80x94corresponding to the memory read-time (or access-time)xe2x80x94the eight bits of data selected by this address 15 become available on the output pins (not shown) of the memory 20 and are propagated on the system""s data bus 24 (in this case, from right to left). The data are gated inside the MPU chip 10 to the instruction register (IR) 26 of the control unit 30, thus completing the fetch cycle.
The two cycles that follow the fetch cycle are decode and execute. The IR 26 is decoded by the decoder 28 that is located within the control unit 30 control unit, usually via a programmable logic-array (PLA) (not shown), and the appropriate signals are generated by the control unit 30, resulting in instruction execution.
An instruction is not necessarily eight bits long. In fact, it generally uses one, two, three, or four words, i.e., 8, 16, 24 or 32 bits. When an instruction has more than eight bits, the control unit 30 must go back to the memory 20 and read the following byte or bytes successively into the IR 26.
The first word of the instruction always contains its opcode, i.e., the binary code that specifies the operation to be done. After decoding the opcode with the decoder 28, the control unit 30 xe2x80x9cknowsxe2x80x9d whether or not it must go back to the memory 20 to fetch additional bytes.
Having described the sequence of events in the execution of a single instruction, we will now describe automatic sequencing, i.e., the sequential execution of instructions. A program is stored as a sequence of binary instructions 14 residing at successive addresses in the memory 20. Once an instruction has been fetched and executed, the program counter (PC) 16 must be updated so that the next instruction can be fetched and executed. The problem lies in updating the program counter 16. This problem is solved by adding an incrementer (or a decrementer depending on the convention used) to the PC 16. Thus, each time the PC 16 is used, (i.e., its contents are output) its value is automatically incremented (or decremented) and loaded back into the PC 16. The next time the PC 16 is used, it will be pointing to the next byte in memory, i.e., to the next instruction or to the next byte of a given instruction, if the instruction uses two bytes or more. This incrementer 32 is shown as +1 in FIG. 1.
Program instructions are stored sequentially (one after another) in the memory 20. However, instructions are not always executed in sequence. In order to take different actions based on the results of tests or decisions, different parts of the program may be executed. In this case, the next instruction to be executed is specified by the current instruction. Such an instruction, which inhibits the automatic sequencing mechanism, is called a branch instruction. The programmer can specify a branch or a jump to a specified memory address. Such an instruction will force a new value within the program counter 16.
From a functional standpoint, the control unit 30 is in charge of sequencing the operation of the entire microprocessor system (as illustrated in FIG. 2). The control unit 230 generates synchronization signals and manages commands exchanged between the arithmetic logic unit of the MPU 210, the I/O 240, and the memory 212. The control unit 230 decodes, fetches, and executes instructions.
The control unit 230 communicates with the external world via input and output lines that make up the control bus 232. The control bus 232 is normally managed by the control unit 230.
Two main techniques are used to design a control unit 230: hard-wiring and microprogramming. Most control units for microprocessors are implemented using a microprogramming technique with a pre-defined instruction set. The sequencing of the control unit is accomplished by a specialized internal program called the microprogram. The microprogram defines the instruction set of the microprocessor and the way it is executed. The microprogram is stored in an internal ROM or PLA 212 inside the chip and is normally invisible to the user. Bit-slices are the only type of LSI chips that are normally user-microprogrammable (because control is external to the slices themselves). For all practical purposes, microprogrammed microprocessors are essentially hardwired, in that they cannot be modified by the user.
There is, therefore, a need in the art for a microcontroller that can be controlled, to some extent, by a user during operation of the microcontroller. There is a further need in the art for a microcontroller that is reconfigurable after it has been manufactured.
The above and other objects of the present invention are satisfied, at least in part by providing, in a microcontroller, a program memory, a decoder, a central processing unit, control logic, and an instruction enabler. The central processing unit is capable of executing instructions within a predefined instruction set. The microcontroller of the present invention optionally can be embedded into appliances or the like.
The microcontroller utilizes the program memory for storing instructions. The decoder fetches the stored instructions and decodes them. An instruction enabler is provided within the microcontroller under the control of the control logic. The instruction enabler receives at least one of the signals that are output by the decoder, i.e., at least one of the decoded instructions. In the preferred embodiment of the present invention, a status bit is checked by the enabler/disabler mechanism to determine whether or not the instruction is to be enabled. If, for example, the status bit is set to ENABLE, then the instruction is enabled, forwarded to the CPU, and execution then proceeds normally. Otherwise for example, if the status bit is set to DISABLE, then the instruction is disabled and is either skipped altogether or is substituted with a no-operation (NOP).
In alternate embodiments of the present invention, the enabler compares the received decoded instruction with a predefined list of special instructions kept by the control logic or the enabler itself, or, in the alternative, a list stored within program memory. If the received coded instruction is found on the list, then the instruction enabler forwards the (enabled) instruction to the central processing unit for execution, or, if the instruction is not found in the list, the decoded instruction is kept from the central processing unit, effectively disabling the instruction. In yet another alternate embodiment of the present invention, the control logic can accommodate hardware switches that affect the selective enablement or disablement of particular instructions within the instruction set. In still another alternate embodiment, software instructions, sent either to the core logic or to the enabler, or contained within the program memory, are used to selectively enable or disable specific instructions and allow the reconfiguration or alteration of behavior of the microcontroller after manufacture.
The present invention also allows a single microcontroller to combine the functionality of several microcontrollers with a common instruction set. The enabler can be set by the user at runtime to enable one or more instruction subsets in order to realize the desired functionality of the specific device. Thus, a single microcontroller can accommodate multiple functions while producing only one common microcontroller, thus reducing manufacturing costs. After production, simply enabling one or more of the instruction subsets in the universal microcontroller alters the subsequent behavior of the device.
One of the unique features of the present invention is the ability to disable certain instructions for security reasons. In some cases, instructions, such as table reads, can be disabled so that would-be crackers are unable to gain access to proprietary software stored in the program memory and/or the data memory. Similarly, selected instructions can be disabled so that, if the program memory or data memory is somehow corrupted, none of the corrupted xe2x80x9cinstructionsxe2x80x9d would be executed, rendering the defective device inert rather than allowing some potentially dangerous action to occur.
Other and further objects, features and advantages will be apparent from the following description of presently preferred embodiments of the invention, given for the purpose of disclosure and taken in conjunction with the accompanying drawings.